﻿using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using CallCenter.Data;
using CallCenter.Data.BizUtilities;
using System.Configuration;
using System.Data;
using CallCenter.Security;
using CallCenter.Data.Models;
using CallCenter.Data.Misc;

namespace CallCenter.Web.Controllers
{
    public class AddProductController : BaseController
    {
        // GET: AddProduct
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult ProductHistory()
        {
            ProductGridViewModel cmpy = new ProductGridViewModel();
            return View(cmpy);
        }
        public JsonResult GetAddProducts()
        {
            var scratchPads = this.Bridge.ProductsUtility.GetAllGrid();
            return Json(scratchPads, JsonRequestBehavior.AllowGet);
        }
        public JsonResult GetAuthorEmployee()
        {
            var scratchPads = this.Bridge.ProductsUtility.GetAuthorEmployee();
            return Json(scratchPads, JsonRequestBehavior.AllowGet);
        }


        public JsonResult GetVendorCompanies()
        {
            var scratchPads = this.Bridge.InvoiceUtility.GetAllGrid();
            return Json(scratchPads, JsonRequestBehavior.AllowGet);
        }



        [HttpPost]
        public JsonResult CreateAddProducts(ProductGridViewModel model)
        {
            var returnMessage = this.Bridge.ProductsUtility.InsertToProduct(model);             
            return Json(returnMessage, JsonRequestBehavior.AllowGet);        
        }

        [HttpPost]
        public JsonResult DeleteAddProduct(ProductGridViewModel model)
        {
         
            int id = model.id;
            this.Bridge.ProductsUtility.Delete(id);
            var returnMessage = "Success";
            return Json(returnMessage, JsonRequestBehavior.AllowGet);

        }

        [HttpPost]
        public JsonResult UpdateAddProduct(ProductGridViewModel model)
        {
           
            var result = this.Bridge.ProductsUtility.UpdateToProduct(model);
            return Json(result, JsonRequestBehavior.AllowGet);
        }


        public ActionResult GetContactDetail()
        {
            var scratchPads = this.Bridge.ccContactUtility.GetContactDetails();

            return Json(scratchPads, JsonRequestBehavior.AllowGet);
        }
    }
}